﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using System.Data;
using System.Data.SqlClient;

namespace DAO
{
    public class ChiTietDonDatHangDAO
    {
        public static bool Insert(ChiTietDonDatHangDTO ctddh)
        {
            bool result = false;

            string strSQLEmployee = "Insert into ChiTietDonDatHang(MaDDH,DonViTinh,SoLuong,ThanhTien,NVL) " +
                "values (@MaDDH,@DVT,@So,@Tien,@NVL)";

            try
            {
                // Create List Sql Parameter
                List<SqlParameter> sqlParams = new List<SqlParameter>();
                sqlParams.Add(new SqlParameter("@MaDDH", ctddh.MaDDH));
                sqlParams.Add(new SqlParameter("@DVT", ctddh.DonViTinh));
                sqlParams.Add(new SqlParameter("@So", ctddh.SoLuong));
                sqlParams.Add(new SqlParameter("@Tien", ctddh.ThanhTien));
                sqlParams.Add(new SqlParameter("@NVL", ctddh.MaNVL));
                // Call execute none query

                int n = SqlDataAccessHelper.ExcuteNoneQuery(strSQLEmployee, sqlParams);//.ExecuteNoneQuery(strSQLEmployee, sqlParams);
                if (n == 1)
                    result = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return result;
        }
    }
}
